package com.atguigu.lease.common.util;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PhoneUtil {
    public static boolean checkPhone(String phone) {
        String regex = "^[1]([3-9])[0-9]{9}$";
        if (StringUtils.isEmpty(phone)) return false;
        else {
            if (phone.length() != 11) return false;
            else {
                Pattern p = Pattern.compile(regex);
                Matcher m = p.matcher(phone);
                boolean isMatch = m.matches();
                if (isMatch) return true;
                else return false;
            }
        }
    }
}
